package org.chainsale.prefuse.action;

import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;

import prefuse.action.distortion.Distortion;

public class ZoomDistortion extends Distortion {

	double radius = 0.1;
	double zoom = 4.0;
	
	public ZoomDistortion() {
		super();
		m_distortX = false;
		m_distortY = false;
	}
	@Override
	protected double distortSize(Rectangle2D bbox, double x, double y,
			Point2D anchor, Rectangle2D bounds) {
		double absRadius = 0.0;
		if (bounds.getWidth() < bounds.getHeight()) {
			absRadius = bounds.getWidth() * radius;
		} else {
			absRadius = bounds.getHeight() * radius;
		}
		double distance = anchor.distance(new Point2D.Double(x,y));
		
		double dr = (absRadius - distance)/absRadius;
		
		if (dr < 0) {
			return(1.0);
		}
		
		double s = dr*zoom + 1;
		
		return(s);
		
	}

	@Override
	protected double distortX(double x, Point2D anchor, Rectangle2D bounds) {
		// TODO Auto-generated method stub
		return x;
	}

	@Override
	protected double distortY(double y, Point2D anchor, Rectangle2D bounds) {
		// TODO Auto-generated method stub
		return y;
	}
	

}
